<?php

namespace api\modules\v1\controllers;

use api\controllers\RestController;
use api\modules\v1\services\CourseSelect;

/**
 * Default controller for the `v1` module
 */
class SelectController extends RestController
{
    public $modelClass = 'api\modules\v1\services\CourseSelect';

    /**
     * 重写create操作，进行用户注册或添加
     * @name: actions
     * @return array
     * @author: rickeryu <lhyfe1987@163.com>
     * @time: 17/11/21 下午4:57
     */
    public function actions() {
        $actions = parent::actions(); // TODO: Change the autogenerated stub
        unset($actions['update'], $actions['delete'], $actions['index'],$actions['view']);
        return $actions;
    }

    /**
     * 返回用户是否已经选择课程
     * @name: actionView
     * @param $course_id
     * @return array|null|\yii\db\ActiveRecord
     * @author: rickeryu <lhyfe1987@163.com>
     * @time: 2017/12/8 下午1:21
     */
    public function actionView($course_id){
        return CourseSelect::info(['course_id'=>$course_id,'user_id'=>\Yii::$app->user->id]);
    }
    
}
